﻿<!DOCTYPE html>
<!--隐患排查内容管理编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>

    <link href="../static/js/vue-treeselect/vue-treeselect.css" rel="stylesheet" />
    <script src="../static/js/vue-treeselect/vue-treeselect.js"></script>
    <style>
        body {
            padding-bottom: 10px;
        }

        .vue-treeselect_style .vue-treeselect__control {
            height: 100%;
            border: none;
            background: none;
        }

        .vue-treeselect__placeholder {
            top: -3px;
        }

        .vue-treeselect__single-value {
            top: -3px;
        }
    </style>
</head>

<body>
    <el-col id="app" v-cloak class="popupW100">
        <el-form :model="Form" status-icon :rules="rules" ref="ruleForm" size="mini" label-position="right">




            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini vue-treeselect_style">
                        <el-form-item prop="unit">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Unit+mark.m}}
                                </template>
                                <treeselect v-model="Form.unit"
                                            :options="department"
                                            :flat="true"
                                            :show-count="true"
                                            slot="suffix"
                                            style="line-height: 28px;"
                                            placeholder="请选择" />
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.unit">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item prop="objective">
                            <el-input type="text" v-model="Form.objective" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Objective+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.objective">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini vue-treeselect_style">
                        <el-form-item prop="personInCharge">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.PersonInCharge+mark.m}}
                                </template>
                                <tree-department-staff-single slot="suffix" v-model="Form.personInCharge" style="line-height:28px;"></tree-department-staff-single>

                            </el-input>
                            <span class="iputLineMust" v-if="!Form.personInCharge">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>

                <el-col :span="11" offset="2">
                    <div class="elst-select-mini vue-treeselect_style">
                        <el-form-item prop="PlanUser">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Participant+mark.m}}
                                </template>
                                <tree-department-staff v-model="Form.PlanUser" :value="Form.PlanUser" :multiple="true"
                                                       :flat="true" :show-count="true" :disable-branch-nodes="true" slot="suffix"
                                                       style="line-height:14px;" placeholder="请选择" />

                            </el-input>
                            <span class="iputLineMust" v-if="!Form.PlanUser">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item prop="requirements">
                            <el-input type="text" v-model="Form.requirements" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Requirements+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.requirements">
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <div class="elst-select-mini">
                        <el-form-item prop="content">
                            <el-input type="text" v-model="Form.content" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Content+mark.m}}
                                </template>
                            </el-input>
                            <span class="iputLineMust" v-if="!Form.content">
                                <!-- 必填项添加 -->
                                <img src="/static/images/exclamation.png" alt="">
                            </span>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="standardType">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskContent.StandardType+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.standardType" slot="suffix"
                                               :placeholder="RisksManagement.RiskContent.StandardType">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in standardType" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.standardType">
                                    <img src="/static/images/exclamation.png" alt="">
                                </span>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="investigationPost">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskContent.InvestigationPost+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.investigationPost" slot="suffix"
                                               :placeholder="RisksManagement.RiskContent.InvestigationPost">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in investigationPost" :label="item.value"
                                                   :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                                <span class="iputLineMust" v-if="!Form.investigationPost">
                                    <img src="/static/images/exclamation.png" alt="">
                                </span>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="standardType">

                                <template slot="prepend">
                                    <div> {{'频次类型'+mark.m}}</div>
                                </template>

                                <el-radio v-model="Form.screeningType" @change="RadioChange" label="日常排查">日常排查</el-radio>
                                <el-radio v-model="Form.screeningType" @change="RadioChange" label="计划排查">计划排查</el-radio>

                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
            </el-row>
            <el-row v-if="frequencyShow">
                <el-col :span="9">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.frequencyText" autocomplete="off" size="mini" readonly>
                                <template slot="prepend">
                                    {{RisksManagement.RiskContent.Frequency+mark.m}}
                                </template>

                            </el-input>

                        </el-form-item>

                    </div>
                </el-col>
                <el-col :span="2" offset="0">
                    <div class="elst-select-mini">
                        <el-button type="primary" @click="onSetFrequency" style="height:28px;margin:1px 0 0 5px;">
                            {{col.btnSetFrequency}}
                        </el-button>
                    </div>
                </el-col>
            </el-row>
            <el-row v-if="!frequencyShow">
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="beginTime">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{'计划开始时间'+mark.m}}</div>
                                    </template>
                                    <el-date-picker slot="suffix" v-model="Form.beginTime" type="datetime" size="mini"
                                                    format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择时间">
                                    </el-date-picker>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>




            </el-row>
            <el-form :inline="true">
                <br>
                <el-row type="flex" justify="begin">

                    <el-form-item>
                        <el-button type="primary" @click="InputInputStand('新增标准知识库','0')">新增标准知识库</el-button>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="InputInputStand('新增基础管理类','1')">新增基础管理类</el-button>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="add">手工添加标准</el-button>
                    </el-form-item>
                </el-row>
            </el-form>
            <!--ListItem.tableHeight   :row-key="getRowKeys"-->
            <el-table ref="table" @current-change="tableHandleCurrentChange" class="tb-edit" :data="Form.yH_ProjectAndDetail"
                      :height="400" border row-style="height:10px" style="width: 100%;margin:0 auto;margin-bottom:20px;">
                <el-table-column :label="RisksManagement.RiskContent.id" width="50">
                    <template slot-scope="props">
                        {{props.$index + 1}}
                    </template>
                </el-table-column>
                <!--添加类型-->
                <el-table-column prop="type" :label="RisksManagement.RiskContent.AddClass">
                </el-table-column>


                <!--排查项目-->
                <el-table-column prop="project" :label="RisksManagement.RiskContent.Project"
                                 show-overflow-tooltip="true">
                    <template scope="scope">
                        <el-input size="mini" v-model="scope.row.project" placeholder="请输入内容">
                        </el-input>
                        <span>{{scope.row.project}}</span>
                        <span class="lineMust" v-if="!scope.row.project">
                            <img src="/static/images/exclamation.png" alt="">
                        </span>
                    </template>
                </el-table-column>
                <!--涉及区域-->
                <el-table-column prop="region" :label="'区域'" align="center"
                                 show-overflow-tooltip="true">
                    <template scope="scope">
                        <el-input size="mini">
                            <treeselect v-model="scope.row.region" :options="AreaList"
                                        slot="suffix"
                                        flat="true"
                                        show-count="true"
                                        style="line-height: 14px;"
                                        placeholder="请选择" />
                        </el-input>
                        <span>{{scope.row.areaName}}</span>
                        <span class="lineMust" v-if="!scope.row.region">
                            <img src="/static/images/exclamation.png" alt="">
                        </span>
                    </template>
                </el-table-column>

                <!--排查标准-->
                <el-table-column prop="standardContent" :label="RisksManagement.RiskContent.Standard" show-overflow-tooltip="true">
                    <template scope="scope">
                        <!--<el-input size="mini" v-model="ListItem.modityShowRow.standardContent" placeholder="请输入内容">
                        </el-input>-->
                        <el-input size="mini" v-model="scope.row.standardContent" placeholder="请输入内容">
                        </el-input>
                        <span>{{scope.row.standardContent}}</span>
                        <!--<span class="lineMust" v-if="!ListItem.modityShowRow.standardContent">
                            <img src="/static/images/exclamation.png" alt="">
                        </span>-->
                    </template>
                </el-table-column>
                <!--隐患级别-->
                <el-table-column prop="riskLevel" :label="RisksManagement.RiskContent.RiskLevel" align="center"
                                 show-overflow-tooltip="true">
                    <template scope="scope">
                        <el-select @visible-change="visibleChange" v-model="scope.row.riskLevel" slot="suffix" size="mini"
                                   :placeholder="RisksManagement.ProcessMedium.RiskLevel">
                            <el-option label="请选择" value=""></el-option>
                            <el-option v-for="item in RiskLevel" :label="item.value" :value="item.key">
                            </el-option>
                        </el-select>
                        <span>{{scope.row.riskLevelText}}</span>
                        <span class="lineMust" v-if="!scope.row.riskLevel">
                            <img src="/static/images/exclamation.png" alt="">
                        </span>
                    </template>
                </el-table-column>

                <!--备注-->
                <el-table-column prop="remark" :label="RisksManagement.RiskContent.Remark" show-overflow-tooltip="true" align="center">
                    <template scope="scope">
                        <el-input size="mini" v-model="scope.row.remark" placeholder="请输入内容">
                        </el-input>
                        <span>{{scope.row.remark}}</span>
                        <span class="lineMust" v-if="!scope.row.remark">
                            <img src="/static/images/exclamation.png" alt="">
                        </span>
                    </template>
                </el-table-column>

                <el-table-column width="90" prop="update" :label="col.btnUpdate">
                    <template slot-scope="scope">
                        <span class="start xian">
                            <button type="button" class="elst-bt-xg" @click=Edit(scope.row,scope.$index)>
                                <i class="el-icon-edit"></i>
                            </button>
                        </span>
                        <span class="end yin">
                            <button type="button" class="elst-bt-xg " @click="Save(scope.row)">
                                <i class="el-icon-circle-check-outline"></i>
                                <!-- 保存 -->
                            </button>
                            <button type="button" class="elst-bt-xg " @click="Back(scope.row)">
                                <i class="el-icon-circle-close-outline"></i>
                                <!-- 撤销 -->
                            </button>
                        </span>
                    </template>
                </el-table-column>


                <el-table-column width="53" prop="update" :label="col.btnDelete" fixed="right" align="center">
                    <template slot-scope="scope">
                        <button type="button" class="elst-bt-xg" @click="deleteRow(scope.row.screeningPlanProDetailId)">
                            <i class="el-icon-delete"></i>
                        </button>
                    </template>
                </el-table-column>

            </el-table>
            <el-row>
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <div class="el-input--mini el-input-group">
                            <div class="el-input-group__prepend">
                                {{RisksManagement.RiskContent.Remark+mark.m}}
                            </div>
                            <el-input class="el-textarea__inner" type="textarea" v-model="Form.remark"
                                      autocomplete="off"></el-input>
                        </div>
                    </div>
                </el-col>
            </el-row>
            <br>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>-->
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSubmit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
        <el-dialog :title="dialogTilte" fullscreen="true" :visible.sync="ListItem.dialogVisible" @close='closeDialog'
                   width="80%" height="80%" top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>

        <script type="text/javascript">
            Vue.component('treeselect', VueTreeselect.Treeselect)
            app = new Vue({
                el: '#app',
                data: {
                    //父业传参
                    id: '',
                    frequencyShow: false,
                    dialogTilte: '',
                    //业务表单内容
                    ListItem: ListItem,
                    InputTable: [],
                    department: [],
                    standardType: [],
                    investigationPost: [],
                    RiskLevel: [],
                    AreaList: [],
                    AllAreaList: [],
                    Form: {
                        id: guidEmpty,
                        unit: null,
                        objective: '',
                        personInCharge: null,
                        PlanUser: [],
                        requirements: '',
                        content: '',
                        standardType: '',
                        investigationPost: '',
                        frequencyText: '',
                        yH_ProjectAndDetail: [],
                        yH_ScreeningPlanProject: []
                    },
                    //表单验证
                    rules: {
                        unit: [verification.NotNull,],
                        objective: [verification.NotNull,],
                        personInCharge: [verification.NotNull,],
                        PlanUser: [verification.NotNull,],
                        requirements: [verification.NotNull,],
                        content: [verification.NotNull,],
                        standardType: [verification.NotNull,],
                        investigationPost: [verification.NotNull,],
                        frequencyText: [verification.NotNull,],
                    }
                },
                methods: {
                    //解決edge下select bug
                    visibleChange: function (isVisible) {
                        visibleChange(isVisible)
                    },
                    // 行内编辑 js
                    add: function (formName) {
                        if ($('tbody tr').attr("class") == "el-table__row current-row") {
                            showMessage(msg.EditingNotCompleted, 'error');
                        } else {


                            $('.el-table__row').removeClass('current-row');
                            $('.el-table__row span.end').removeClass('xian');
                            $('.el-table__row span.end').addClass('yin');
                            $('.el-table__row span.start').removeClass('yin');
                            $('.el-table__row span.start').addClass('xian');


                            this.ListItem.type = 'tj';
                            var screeningPlanProDetailId = newGuid()
                            //显示用
                            var newObj = {
                                screeningPlanProDetailId: screeningPlanProDetailId,
                                type: "手工",
                                region: null,
                                areaName: '',
                                standardContent: '',
                                //  riskOfViolation: 'riskOfViolation',//
                                riskLevel: '',
                                riskLevelText: '',
                                // standardID: '5eee8a95-64c9-49cc-b1d1-08d782b3c1e8',//
                                searchMajorCode: 'YH_Custom',
                                searchMajorCodeName: '手工添加类',
                                project: '',
                                remark: '',
                                //screeningPlanProjectId: newGuid(),
                            }
                            if (!this.Form.yH_ProjectAndDetail) this.Form.yH_ProjectAndDetail = [];
                            this.Form.yH_ProjectAndDetail.unshift(newObj);
                            console.log("this.Form.yH_ProjectAndDetail", this.Form.yH_ProjectAndDetail);

                            ////提交数据用
                            //var detailList = [
                            //    {
                            //        type: "手工",
                            //        region: null,
                            //        standardContent: '',
                            //        riskLevel: '',
                            //        //standardID: v.standardID,
                            //        searchMajorCode: 'YH_Custom',
                            //        screeningPlanProDetailId: screeningPlanProDetailId
                            //    }
                            //];
                            //var project = {
                            //    project: '',
                            //    remark: '',
                            //    yH_ScreeningPlanProDetail: detailList
                            //}
                            //if (!this.Form.yH_ScreeningPlanProject) this.Form.yH_ScreeningPlanProject = [];
                            //this.Form.yH_ScreeningPlanProject.push(project);





                            setTimeout(function () {
                                $('.el-table__row:eq(0)').addClass('current-row');
                                $('.el-table__row:eq(0) span.end').removeClass('yin');
                                $('.el-table__row:eq(0) span.end').addClass('xian');
                                $('.el-table__row:eq(0) span.start').removeClass('xian');
                                $('.el-table__row:eq(0) span.start').addClass('yin');
                            }, 100);
                        }
                    },
                    //修改
                    Edit: function (row, index) {
                        $('.el-table__row').removeClass('current-row');
                        $('.el-table__row:eq(' + index + ')').addClass('current-row');
                        $('.el-table__row span.end').removeClass('xian');
                        $('.el-table__row span.end').addClass('yin');
                        $('.el-table__row span.start').removeClass('yin');
                        $('.el-table__row span.start').addClass('xian');
                        $('.el-table__row:eq(' + index + ') span.end').removeClass('yin');
                        $('.el-table__row:eq(' + index + ') span.end').addClass('xian');
                        $('.el-table__row:eq(' + index + ') span.start').removeClass('xian');
                        $('.el-table__row:eq(' + index + ') span.start').addClass('yin');
                        this.ListItem.type = 'xg';
                        //var a = {};
                        //$.extend(a, row, true);
                        //this.ListItem.modityShowRow = a;

                        this.ListItem.modityShowRow = $.extend({}, row);

                        // console.log(this.ListItem.modityShowRow.standardContent)
                    },
                    // 保存 注意去掉mock中的parent 否则无法保存
                    Save: function (b) {
                        if (!b.project) {
                            showMessage(msg.NoMust, 'error');
                        }
                        else {
                            ////b = $.extend({}, this.ListItem.modityShowRow);
                            ////console.log('b', b)
                            //$.extend(b, this.ListItem.modityShowRow);
                            b.riskLevelText = this.GetRiskLevelName(b.riskLevel)
                            b.areaName = this.GetAreaName(b.region);

                            console.log('this.ListItem.type', this.ListItem.type)

                            if (this.ListItem.type == 'xg') {
                                var projects = this.Form.yH_ScreeningPlanProject;
                                for (var i = 0; i < projects.length; i++) {

                                    for (var j = 0; j < projects[i].yH_ScreeningPlanProDetail.length; j++) {
                                        var detail = projects[i].yH_ScreeningPlanProDetail[j];
                                        if (detail.screeningPlanProDetailId == b.screeningPlanProDetailId) {
                                            projects[i].project = b.project;
                                            projects[i].remark = b.remark;
                                            detail.region = b.region;
                                            detail.standardContent = b.standardContent;
                                            detail.riskLevel = b.riskLevel;
                                        }
                                    }
                                }
                            }
                            else if (this.ListItem.type == 'tj') {
                                //提交数据用
                                var detailList = [
                                    {
                                        type: "手工",
                                        region: b.region,
                                        standardContent: b.standardContent,
                                        riskLevel: b.riskLevel,
                                        searchMajorCode: 'YH_Custom',
                                        screeningPlanProDetailId: b.screeningPlanProDetailId
                                    }
                                ];
                                var project = {
                                    project: b.project,
                                    remark: b.remark,
                                    yH_ScreeningPlanProDetail: detailList
                                }
                                if (!this.Form.yH_ScreeningPlanProject) this.Form.yH_ScreeningPlanProject = [];
                                this.Form.yH_ScreeningPlanProject.push(project);
                            }
                            $('.el-table__row').removeClass('current-row');
                            $('.el-table__row span.end').removeClass('xian');
                            $('.el-table__row span.end').addClass('yin');
                            $('.el-table__row span.start').removeClass('yin');
                            $('.el-table__row span.start').addClass('xian');
                        }
                    },
                    Back: function (row) {
                        $('.el-table__row').removeClass('current-row');
                        $('.el-table__row span.end').removeClass('xian');
                        $('.el-table__row span.end').addClass('yin');
                        $('.el-table__row span.start').removeClass('yin');
                        $('.el-table__row span.start').addClass('xian');
                        dianX(row, this.Form.yH_ProjectAndDetail);
                    },
                    //table选中行handle
                    tableHandleCurrentChange: function (currentRow) {
                        if (currentRow) {
                            this.currSeelctId = currentRow.id;
                            this.currSeelctCell = currentRow;
                        }

                    },
                    //移除
                    deleteRow: function (id) {
                        $('.el-table__row').removeClass('current-row');
                        $('.el-table__row span.end').removeClass('xian');
                        $('.el-table__row span.end').addClass('yin');
                        $('.el-table__row span.start').removeClass('yin');
                        $('.el-table__row span.start').addClass('xian');
                        var temp = [];
                        var Standard = this.Form.yH_ProjectAndDetail;

                        //先删除用于显示的数据集合
                        for (var i = 0; i < Standard.length; i++) {
                            temp.push(Standard[i]);
                        }
                        for (var i = temp.length - 1; i >= 0; i--) {
                            if (id == temp[i].screeningPlanProDetailId) {
                                Standard.splice(i, 1);
                            }
                        }

                        //提交数据对象
                        var project = this.Form.yH_ScreeningPlanProject;
                        var projectTemp = [];
                        //保存提交数据项目对象到临时集合对象
                        for (var i = 0; i < project.length; i++) {
                            projectTemp.push(project[i]);
                        }
                        //遍历提交项目数据
                        for (var i = 0; i < project.length; i++) {
                            //项目详细
                            var detail = project[i].yH_ScreeningPlanProDetail
                            var temp2 = [];
                            for (var j = 0; j < detail.length; j++) {
                                temp2.push(detail[j]);
                            }
                            //删除详细
                            for (var k = temp2.length - 1; k >= 0; k--) {
                                console.log(id, temp2[k].screeningPlanProDetailId)
                                console.log(id == temp2[k].screeningPlanProDetailId)
                                if (id == temp2[k].screeningPlanProDetailId) {
                                    console.log('执行删除', detail.length)
                                    detail.splice(k, 1);
                                    console.log('执行删除', detail.length)
                                }
                            }

                        }



                        //删除后的项目下的详细集合数量如果为0，则把该项目也删除，避免冗余数据
                        for (var l = projectTemp.length - 1; l >= 0; l--) {
                            var detail = projectTemp[l].yH_ScreeningPlanProDetail;
                            if (!detail) detail = [];
                            if (detail.length == 0) {
                                project.splice(l, 1);
                            }
                        }

                    },
                    //提交数据
                    onSubmitForm: function (formName) {
                        var mythis = this;
                        this.$refs[formName].validate(function (valid) {
                            //验证通过
                            if (valid) {

                                //处理参与人对象
                                if (mythis.Form.PlanUser) {
                                    mythis.Form.yH_ScreeningPlanUser = [];
                                    for (var i = 0; i < mythis.Form.PlanUser.length; i++) {
                                        mythis.Form.yH_ScreeningPlanUser.push({
                                            userId: mythis.Form.PlanUser[i]
                                        })
                                    }
                                }
                                console.log('显示', mythis.Form.yH_ProjectAndDetail);
                                console.log('数据', mythis.Form.yH_ScreeningPlanProject);
                                onSubmitForm(this, '/api/YH_ScreeningPlan/Save', mythis.Form);
                            } else {
                                //验证失败
                                return false;
                            }
                        });

                    },
                    //获取input数据
                    getData: function () {
                        getData(this, '/api/YH_ScreeningPlan/get?id=' + this.id);
                    },
                    //设置频次
                    onSetFrequency: function () {
                        this.dialogTilte = "设置频次";
                        DialogShow(this, "xg", "RiskContentSetFrequency.html", this.id);
                    },
                    //新增知识库
                    InputInputStand: function (val, type) {
                        this.dialogTilte = val;
                        if (type == "0")
                            DialogShow(this, 'xg', "RiskContentSetProject.html", this.id);
                        else if (type == "1")
                            DialogShow(this, 'xg', "RiskContentSetBasicProject.html", this.id);
                    },
                    //dialog关闭触发
                    closeDialog: function () {
                        //this.ListItem.tableData = this.Form.InputTable;

                        if (this.Form.screeningType == "计划排查") {
                            //重置提醒频次文本
                            this.ShowFrequencyText();
                        }
                    },
                    //提醒频次文本
                    ShowFrequencyText: function () {
                        var dto = this.Form;
                        if (dto.screeningType == "计划排查") {
                            var moveUp = "，提前" + dto.moveUp + "天提醒";
                            if (dto.moveUp == 0 || dto.moveUp == null) {
                                moveUp = "，不提醒";
                            }
                            switch (dto.type) {
                                case "0": result = "每年执行1次" + moveUp; break;
                                case "1": result = "每月执行1次" + moveUp; break;
                                case "2": result = "每周执行1次" + moveUp; break;
                                case "3": result = "每天执行1次"; break;
                                case "4": result = "在" + dto.beginTimeByCustom + "执行1次" + moveUp; break;
                                default: result = "数据异常"; break;
                            }
                        }
                        else {
                            result = "每天执行1次";
                        }
                        this.Form.frequencyText = result;
                    },
                    //初始化部门下拉树
                    getDepartmentData: function () {
                        var mythis = this;
                        myAjax("post", this, '/api/SysDepartment/GetListSub', null, function (response) {
                            mythis.department = menuHelperX(response.data.pageData, guidEmpty)
                        }, false);
                    },
                    //radio事件
                    RadioChange: function (v) {
                        if (v == '计划排查') this.frequencyShow = true;
                        else this.frequencyShow = false;
                    },
                    GetAreaList: function (type) {
                        var mythis = this;
                        myAjax("post", this, '/api/SysArea/GetListSub', { model: { Name: '', Code: '', SubFactory: null }, offset: 0, limit: 999 }
                            , function (response) {
                                mythis.AllAreaList = response.data.pageData;
                                mythis.AreaList = menuHelperX(response.data.pageData, guidEmpty);
                            },
                            false);
                    },
                    GetAreaName: function (id) {
                        var AllAreaList = this.AllAreaList;
                        for (var i = 0; i < AllAreaList.length; i++) {
                            if (AllAreaList[i].id == id) {
                                return AllAreaList[i].name;
                            }
                        }
                        return id;
                    },
                    GetRiskLevelName: function (id) {
                        var RiskLevel = this.RiskLevel;
                        for (var i = 0; i < RiskLevel.length; i++) {
                            if (RiskLevel[i].key == id) {
                                return RiskLevel[i].value;
                            }
                        }
                        return id;
                    }
                },
                mounted: function () {
                    //this.ListItem.modityShowRow = {
                    //    standardContent:''
                    //}
                    this.GetAreaList();
                    this.getDepartmentData();
                    this.RiskLevel = getDicData('03');
                    this.standardType = getDicData('102');//排查标准类型
                    this.investigationPost = getDicData('60');//排查岗位
                    //获取传值id
                    this.id = getUrlParam("id");

                    //读取数据
                    this.getData();
                    //读取数据到表格数据对象
                    //this.ListItem.tableData = this.Form.yH_ProjectAndDetail;
                    //根据radio控制显隐
                    this.RadioChange(this.Form.screeningType);
                    //参与人下拉树赋值
                    if (this.Form.yH_ScreeningPlanUser) {
                        this.Form.PlanUser = [];
                        for (var i = 0; i < this.Form.yH_ScreeningPlanUser.length; i++) {
                            this.Form.PlanUser.push(this.Form.yH_ScreeningPlanUser[i].userId)
                        }
                    }

                }
            });
            //下拉树数据格式化
            function menuHelperX(list, pid) {
                var result = [];
                if (list.length <= 0)
                    return list;
                list.forEach(function (v, i) {
                    var temp = {};
                    for (var key in v) {
                        temp[key] = v[key];
                    }
                    temp.label = v.name;
                    temp.parentId = temp.parentId ? temp.parentId : guidEmpty;
                    var obj;
                    if (temp.parentId == pid) {
                        obj = temp;
                        var nextObj = menuHelperX(list, temp.id);
                        if (nextObj.length > 0) {
                            obj.children = nextObj;
                        }
                    }
                    if (obj)
                        result.push(obj)
                })
                return result;
            }
        </script>
</body>

</html>
